package cn.tsinghua.comsmacitccntsinghua.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;

import cn.tsinghua.comsmacitccntsinghua.ui.MainActivity;

/**
 * @Author yjl
 * @create 2021/9/14 9:09
 */
public class PowerBootReceiver extends BroadcastReceiver {

    final static String ACTION = "android.intent.action.BOOT_COMPLETED";

    @Override
    public void onReceive(Context context, Intent intent) {
        if(intent.getAction().equals(ACTION)){
            Intent openIntent = new Intent(context, MainActivity.class);
            openIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    context.startActivity(openIntent);
                }
            },5000);
        }
    }

}
